<!DOCTYPE html>
<html>
<!--
Copyright 2006 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by an Apache 2.0 License.
See the COPYING file for details.
-->
<head>
<title>Closure Unit Tests - goog.locale.DateTimeFormat</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.locale');
  goog.require('goog.locale.formatting');
  goog.require('goog.locale.DateTimeFormat');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>
  // there is problem in running this unittest in distributed mode in
  // accessing symbols. So we include symbol here to get around this issue.
  var DateTimeConstants_de = {
    ERAS:["v. Chr.", "n. Chr."],
    ERANAMES:["v. Chr.", "n. Chr."],
    NARROWMONTHS:["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
    MONTHS:["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli",
        "August", "September", "Oktober", "November", "Dezember"],
    SHORTMONTHS:["Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep",
        "Okt", "Nov", "Dez"],
    WEEKDAYS:["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag",
        "Freitag", "Samstag"],
    SHORTWEEKDAYS:["So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."],
    NARROWWEEKDAYS:["S", "M", "D", "M", "D", "F", "S"],
    SHORTQUARTERS:["Q1", "Q2", "Q3", "Q4"],
    QUARTERS:["1. Quartal", "2. Quartal", "3. Quartal", "4. Quartal"],
    AMPMS:["vorm.", "nachm."],
    DATEFORMATS:["EEEE, d. MMMM yyyy", "d. MMMM yyyy", "dd.MM.yyyy",
        "dd.MM.yy"],
    TIMEFORMATS:["H:mm' Uhr 'z", "HH:mm:ss z", "HH:mm:ss", "HH:mm"],
    ZONESTRINGS:null
  };

  DateTimeConstants_de.STANDALONENARROWMONTHS =
      DateTimeConstants_de.NARROWMONTHS;
  DateTimeConstants_de.STANDALONEMONTHS =
      DateTimeConstants_de.MONTHS;
  DateTimeConstants_de.STANDALONESHORTMONTHS =
      DateTimeConstants_de.SHORTMONTHS;
  DateTimeConstants_de.STANDALONEWEEKDAYS = DateTimeConstants_de.WEEKDAYS;
  DateTimeConstants_de.STANDALONESHORTWEEKDAYS =
      DateTimeConstants_de.SHORTWEEKDAYS;
  DateTimeConstants_de.STANDALONENARROWWEEKDAYS =
      DateTimeConstants_de.NARROWWEEKDAYS;

  registerDateTimeConstants(DateTimeConstants_de, 'de');

  // Helpers to make tests work regardless of the timeZone we're in.
  function timezoneString(date) {
    var timeZone = goog.locale.TimeZone.createTimeZone(
        date.getTimezoneOffset());
    return timeZone.getShortName(date);
    //return (new goog.locale.DateTimeFormat()).formatGMT_(1, date);
  }

  function timezoneStringRFC(date) {
    var timeZone = goog.locale.TimeZone.createTimeZone(
        date.getTimezoneOffset());
    return timeZone.getRFCTimeZoneString(date);
  }

  // Where could such data be found
  // In js_i18n_data in http://go/i18n_dir, we have a bunch of files with names
  // like TimeZoneConstant__<locale>.js
  // We strongly discourage you to use them directly as those data can make
  // your client code bloated. You should try to provide this data from server
  // in a selective manner. In typical scenario, user's time zone is retrieved
  // and only data for that time zone should be provided.
  var americaLosAngelesData = {
    "transitions": [
      2770, 60, 7137, 0, 11506, 60, 16041, 0, 20410, 60, 24777, 0, 29146, 60,
      33513, 0, 35194, 60, 42249, 0, 45106, 60, 50985, 0, 55354, 60, 59889, 0,
      64090, 60, 68625, 0, 72994, 60, 77361, 0, 81730, 60, 86097, 0, 90466, 60,
      94833, 0, 99202, 60, 103569, 0, 107938, 60, 112473, 0, 116674, 60, 121209,
      0, 125578, 60, 129945, 0, 134314, 60, 138681, 0, 143050, 60, 147417, 0,
      151282, 60, 156153, 0, 160018, 60, 165057, 0, 168754, 60, 173793, 0,
      177490, 60, 182529, 0, 186394, 60, 191265, 0, 195130, 60, 200001, 0,
      203866, 60, 208905, 0, 212602, 60, 217641, 0, 221338, 60, 226377, 0,
      230242, 60, 235113, 0, 238978, 60, 243849, 0, 247714, 60, 252585, 0,
      256450, 60, 261489, 0, 265186, 60, 270225, 0, 273922, 60, 278961, 0,
      282826, 60, 287697, 0, 291562, 60, 296433, 0, 300298, 60, 305337, 0,
      309034, 60, 314073, 0, 317770, 60, 322809, 0, 326002, 60, 331713, 0,
      334738, 60, 340449, 0, 343474, 60, 349185, 0, 352378, 60, 358089, 0,
      361114, 60, 366825, 0, 369850, 60, 375561, 0, 378586, 60, 384297, 0,
      387322, 60, 393033, 0, 396058, 60, 401769, 0, 404962, 60, 410673, 0,
      413698, 60, 419409, 0, 422434, 60, 428145, 0, 431170, 60, 436881, 0,
      439906, 60, 445617, 0, 448810, 60, 454521, 0, 457546, 60, 463257, 0,
      466282, 60, 471993, 0, 475018, 60, 480729, 0, 483754, 60, 489465, 0,
      492490, 60, 498201, 0, 501394, 60, 507105, 0, 510130, 60, 515841, 0,
      518866, 60, 524577, 0, 527602, 60, 533313, 0, 536338, 60, 542049, 0,
      545242, 60, 550953, 0, 553978, 60, 559689, 0, 562714, 60, 568425, 0,
      571450, 60, 577161, 0, 580186, 60, 585897, 0, 588922, 60, 594633, 0
    ],
    "names": ["PST", "Pacific Standard Time", "PDT", "Pacific Daylight Time"],
    "id": "America/Los_Angeles",
    "std_offset": -480
  };

  var europeBerlinData = {
    "transitions": [
      89953, 60, 94153, 0, 98521, 60, 102889, 0, 107257, 60, 111625, 0,
      115993, 60, 120361, 0, 124729, 60, 129265, 0, 133633, 60, 138001, 0,
      142369, 60, 146737, 0, 151105, 60, 155473, 0, 159841, 60, 164209, 0,
      168577, 60, 172945, 0, 177313, 60, 181849, 0, 186217, 60, 190585, 0,
      194953, 60, 199321, 0, 203689, 60, 208057, 0, 212425, 60, 216793, 0,
      221161, 60, 225529, 0, 230065, 60, 235105, 0, 238801, 60, 243841, 0,
      247537, 60, 252577, 0, 256273, 60, 261481, 0, 265009, 60, 270217, 0,
      273745, 60, 278953, 0, 282649, 60, 287689, 0, 291385, 60, 296425, 0,
      300121, 60, 305329, 0, 308857, 60, 314065, 0, 317593, 60, 322801, 0,
      326329, 60, 331537, 0, 335233, 60, 340273, 0, 343969, 60, 349009, 0,
      352705, 60, 357913, 0, 361441, 60, 366649, 0, 370177, 60, 375385, 0,
      379081, 60, 384121, 0, 387817, 60, 392857, 0, 396553, 60, 401593, 0,
      405289, 60, 410497, 0, 414025, 60, 419233, 0, 422761, 60, 427969, 0,
      431665, 60, 436705, 0, 440401, 60, 445441, 0, 449137, 60, 454345, 0,
      457873, 60, 463081, 0, 466609, 60, 471817, 0, 475513, 60, 480553, 0,
      484249, 60, 489289, 0, 492985, 60, 498025, 0, 501721, 60, 506929, 0,
      510457, 60, 515665, 0, 519193, 60, 524401, 0, 528097, 60, 533137, 0,
      536833, 60, 541873, 0, 545569, 60, 550777, 0, 554305, 60, 559513, 0,
      563041, 60, 568249, 0, 571777, 60, 576985, 0, 580681, 60, 585721, 0,
      589417, 60, 594457, 0],
    "names": ["MEZ", "Mitteleurop\u00e4ische Zeit",
              "MESZ", "Mitteleurop\u00e4ische Sommerzeit"],
    "id": "Europe/Berlin",
    "std_offset": 60
  };

  var date;
  goog.locale.setLocale('de');

  function testHHmmss() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("13:10:10", goog.locale.formatDateTime("HH:mm:ss", date));
  }

  function testhhmmssa() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("1:10:10 nachm.",
                 goog.locale.formatDateTime("h:mm:ss a", date));
  }

  function testEEEMMMddyy() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("Do., Jul 27, 06",
                 goog.locale.formatDateTime("EEE, MMM d, yy", date));
  }

  function testEEEEMMMddyy() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("Donnerstag,Juli 27, 2006",
                 goog.locale.formatDateTime("EEEE,MMMM dd, yyyy", date));
  }

  function testyyyyMMddG() {
    date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10, 250));
    var timeZone = goog.locale.TimeZone.createTimeZone(420);
    assertEquals("2006.07.27 n. Chr. at 06:10:10 Etc/GMT+7",
        goog.locale.formatDateTime("yyyy.MM.dd G 'at' HH:mm:ss vvvv",
                                   date, timeZone));
  }

  function testyyyyyMMMMM() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("2006.J.27 n. Chr. 01:10 nachm.",
                 goog.locale.formatDateTime("yyyyy.MMMMM.dd GGG hh:mm aaa",
                                            date));
  }

  function testQQQQyy() {
    date = new Date(2006, 0, 27, 13, 10, 10, 250);
    assertEquals("1. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 1, 27, 13, 10, 10, 250);
    assertEquals("1. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 2, 27, 13, 10, 10, 250);
    assertEquals("1. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 3, 27, 13, 10, 10, 250);
    assertEquals("2. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 4, 27, 13, 10, 10, 250);
    assertEquals("2. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 5, 27, 13, 10, 10, 250);
    assertEquals("2. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("3. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 7, 27, 13, 10, 10, 250);
    assertEquals("3. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 8, 27, 13, 10, 10, 250);
    assertEquals("3. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 9, 27, 13, 10, 10, 250);
    assertEquals("4. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 10, 27, 13, 10, 10, 250);
    assertEquals("4. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
    date = new Date(2006, 11, 27, 13, 10, 10, 250);
    assertEquals("4. Quartal 06",
                 goog.locale.formatDateTime("QQQQ yy", date));
  }

  function testQQyyyy() {
    date = new Date(2006, 0, 27, 13, 10, 10, 250);
    assertEquals("Q1 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 1, 27, 13, 10, 10, 250);
    assertEquals("Q1 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 2, 27, 13, 10, 10, 250);
    assertEquals("Q1 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 3, 27, 13, 10, 10, 250);
    assertEquals("Q2 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 4, 27, 13, 10, 10, 250);
    assertEquals("Q2 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 5, 27, 13, 10, 10, 250);
    assertEquals("Q2 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("Q3 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 7, 27, 13, 10, 10, 250);
    assertEquals("Q3 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 8, 27, 13, 10, 10, 250);
    assertEquals("Q3 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 9, 27, 13, 10, 10, 250);
    assertEquals("Q4 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 10, 27, 13, 10, 10, 250);
    assertEquals("Q4 2006", goog.locale.formatDateTime("QQ yyyy", date));
    date = new Date(2006, 11, 27, 13, 10, 10, 250);
    assertEquals("Q4 2006", goog.locale.formatDateTime("QQ yyyy", date));
  }

  function testMMddyyyyHHmmsszzz() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("07/27/2006 13:10:10 " + timezoneString(date),
        goog.locale.formatDateTime("MM/dd/yyyy HH:mm:ss zzz", date));
  }

  function testMMddyyyyHHmmssZ() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("07/27/2006 13:10:10 " + timezoneStringRFC(date),
        goog.locale.formatDateTime("MM/dd/yyyy HH:mm:ss Z", date));
  }

  function testQuote() {
    date = new Date(2006, 6, 27, 13, 10, 10, 250);
    assertEquals("13 o'clock", goog.locale.formatDateTime("HH 'o''clock'",
                                                          date));
    assertEquals("13 oclock", goog.locale.formatDateTime("HH 'oclock'", date));
    assertEquals("13 '", goog.locale.formatDateTime("HH ''", date));
  }

  function testPredefinedFormat() {
    date = new Date(2006, 7, 4, 13, 49, 24, 000);
    assertEquals("Freitag, 4. August 2006",
       goog.locale.standardFormatDateTime(goog.locale.FULL_DATE_FORMAT, date));
    assertEquals("4. August 2006",
       goog.locale.standardFormatDateTime(goog.locale.LONG_DATE_FORMAT, date));
    assertEquals("04.08.2006",
       goog.locale.standardFormatDateTime(goog.locale.MEDIUM_DATE_FORMAT, date));
    assertEquals("04.08.06",
       goog.locale.standardFormatDateTime(goog.locale.SHORT_DATE_FORMAT, date));
    assertEquals("13:49 Uhr " + timezoneString(date),
       goog.locale.standardFormatDateTime(goog.locale.FULL_TIME_FORMAT, date));
    assertEquals("13:49:24 " + timezoneString(date),
       goog.locale.standardFormatDateTime(goog.locale.LONG_TIME_FORMAT, date));
    assertEquals("13:49:24",
       goog.locale.standardFormatDateTime(goog.locale.MEDIUM_TIME_FORMAT, date));
    assertEquals("13:49",
       goog.locale.standardFormatDateTime(goog.locale.SHORT_TIME_FORMAT, date));
    assertEquals("Freitag, 4. August 2006 13:49 Uhr " + timezoneString(date),
       goog.locale.standardFormatDateTime(goog.locale.FULL_DATETIME_FORMAT,
                                          date));
    assertEquals("4. August 2006 13:49:24 " + timezoneString(date),
       goog.locale.standardFormatDateTime(goog.locale.LONG_DATETIME_FORMAT,
                                          date));
    assertEquals("04.08.2006 13:49:24",
       goog.locale.standardFormatDateTime(goog.locale.MEDIUM_DATETIME_FORMAT,
                                          date));
    assertEquals("04.08.06 13:49",
       goog.locale.standardFormatDateTime(goog.locale.SHORT_DATETIME_FORMAT,
                                          date));
  }

  function testFractionalSeconds() {
    date = new Date(2006, 6, 27, 13, 10, 10, 256);
    assertEquals("10:3", goog.locale.formatDateTime("s:S", date));
    assertEquals("10:26", goog.locale.formatDateTime("s:SS", date));
    assertEquals("10:256", goog.locale.formatDateTime("s:SSS", date));
    assertEquals("10:2560", goog.locale.formatDateTime("s:SSSS", date));
    assertEquals("10:25600", goog.locale.formatDateTime("s:SSSSS", date));
  }

  function testPredefinedFormatter() {
    date = new Date(2006, 7, 4, 13, 49, 24, 000);
    assertEquals("Freitag, 4. August 2006",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.FULL_DATE_FORMAT).format(date));
    assertEquals("4. August 2006",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.LONG_DATE_FORMAT).format(date));
    assertEquals("04.08.2006",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.MEDIUM_DATE_FORMAT).format(date));
    assertEquals("04.08.06",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.SHORT_DATE_FORMAT).format(date));
    assertEquals("13:49 Uhr " + timezoneString(date),
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.FULL_TIME_FORMAT).format(date));
    assertEquals("13:49:24 " + timezoneString(date),
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.LONG_TIME_FORMAT).format(date));
    assertEquals("13:49:24",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.MEDIUM_TIME_FORMAT).format(date));
    assertEquals("13:49",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.SHORT_TIME_FORMAT).format(date));
    assertEquals("Freitag, 4. August 2006 13:49 Uhr " + timezoneString(date),
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.FULL_DATETIME_FORMAT).format(date));
    assertEquals("4. August 2006 13:49:24 " + timezoneString(date),
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.LONG_DATETIME_FORMAT).format(date));
    assertEquals("04.08.2006 13:49:24",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.MEDIUM_DATETIME_FORMAT).format(date));
    assertEquals("04.08.06 13:49",
       goog.locale.getStandardDateTimeFormatter(
       goog.locale.SHORT_DATETIME_FORMAT).format(date));
  }

  function testMMddyyyyHHmmssZSimpleTimeZone() {
    var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(480);
    assertEquals("07/27/2006 05:10:10 -0800",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss Z").format(
        date, timeZone));
    assertEquals("07/27/2006 05:10:10 -0800",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZ").format(
        date, timeZone));
    assertEquals("07/27/2006 05:10:10 -0800",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZZ").format(
        date, timeZone));
    assertEquals("07/27/2006 05:10:10 GMT-08:00",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZZZ").format(
        date, timeZone));
  }


  function testMMddyyyyHHmmssZCommonTimeZone() {
    var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(americaLosAngelesData);
    assertEquals("07/27/2006 06:10:10 -0700",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss Z").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 -0700",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZ").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 -0700",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZZ").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 GMT-07:00",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZZZ").format(
        date, timeZone));

    date = new Date(Date.UTC(2006, 1, 27, 13, 10, 10));
    assertEquals("02/27/2006 05:10:10 -0800",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss Z").format(
        date, timeZone));
    assertEquals("02/27/2006 05:10:10 -0800",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZ").format(
        date, timeZone));
    assertEquals("02/27/2006 05:10:10 -0800",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZZ").format(
        date, timeZone));
    assertEquals("02/27/2006 05:10:10 GMT-08:00",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss ZZZZ").format(
        date, timeZone));
  }

  function testMMddyyyyHHmmsszSimpleTimeZone() {
    var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(420);
    assertEquals("07/27/2006 06:10:10 UTC-7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss z").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 UTC-7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zz").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 UTC-7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzz").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 UTC-7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzzz").format(
        date, timeZone));
  }


  function testMMddyyyyHHmmsszCommonTimeZone() {
    var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(americaLosAngelesData);
    assertEquals("07/27/2006 06:10:10 PDT",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss z").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 PDT",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zz").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 PDT",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzz").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 Pacific Daylight Time",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzzz").format(
        date, timeZone));

    date = new Date(Date.UTC(2006, 1, 27, 13, 10, 10));
    assertEquals("02/27/2006 05:10:10 PST",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss z").format(
        date, timeZone));
    assertEquals("02/27/2006 05:10:10 PST",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zz").format(
        date, timeZone));
    assertEquals("02/27/2006 05:10:10 PST",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzz").format(
        date, timeZone));
    assertEquals("02/27/2006 05:10:10 Pacific Standard Time",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzzz").format(
        date, timeZone));

    timeZone = goog.locale.TimeZone.createTimeZone(europeBerlinData);
    assertEquals("02/27/2006 14:10:10 MEZ",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss z").format(
        date, timeZone));
    assertEquals("02/27/2006 14:10:10 Mitteleurop\u00e4ische Zeit",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss zzzz").format(
        date, timeZone));
  }

  function testMMddyyyyHHmmssvCommonTimeZone() {
    var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(americaLosAngelesData);
    assertEquals("07/27/2006 06:10:10 America/Los_Angeles",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss v").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 America/Los_Angeles",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss vv").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 America/Los_Angeles",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss vvv").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 America/Los_Angeles",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss vvvv").format(
        date, timeZone));
  }

  function testMMddyyyyHHmmssvSimpleTimeZone() {
    var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(420);
    assertEquals("07/27/2006 06:10:10 Etc/GMT+7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss v").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 Etc/GMT+7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss vv").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 Etc/GMT+7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss vvv").format(
        date, timeZone));
    assertEquals("07/27/2006 06:10:10 Etc/GMT+7",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss vvvv").format(
        date, timeZone));
  }


  function test_yyyyMMddG() {
    var date = new Date(Date.UTC(2006, 6, 27, 20, 10, 10));
    var timeZone = goog.locale.TimeZone.createTimeZone(420);
    assertEquals("2006.07.27 n. Chr. at 13:10:10 Etc/GMT+7",
        goog.locale.getDateTimeFormatter(
        "yyyy.MM.dd G 'at' HH:mm:ss vvvv").format(date, timeZone));

    timeZone = goog.locale.TimeZone.createTimeZone(americaLosAngelesData);
    assertEquals("2006.07.27 n. Chr. at 13:10:10 America/Los_Angeles",
        goog.locale.getDateTimeFormatter(
        "yyyy.MM.dd G 'at' HH:mm:ss vvvv").format(date, timeZone));
  }

  function test_daylightTimeTransition() {
    // US PST transition to PDT on 2006/4/2/ 2:00am, jump to 2006/4/2 3:00am,
    // That's UTC time 2006/4/2 10:00am
    var timeZone = goog.locale.TimeZone.createTimeZone(americaLosAngelesData);
    var date = new Date(Date.UTC(2006, 4 - 1, 2, 9, 59, 0));
    assertEquals("04/02/2006 01:59:00 PST",
        goog.locale.getDateTimeFormatter(
        "MM/dd/yyyy HH:mm:ss z").format(date, timeZone));
    date = new Date(Date.UTC(2006, 4 - 1, 2, 10, 01, 0));
    assertEquals("04/02/2006 03:01:00 PDT",
        goog.locale.getDateTimeFormatter(
        "MM/dd/yyyy HH:mm:ss z").format(date, timeZone));
    date = new Date(Date.UTC(2006, 4 - 1, 2, 10, 00, 0));
    assertEquals("04/02/2006 03:00:00 PDT",
        goog.locale.getDateTimeFormatter(
        "MM/dd/yyyy HH:mm:ss z").format(date, timeZone));
  }

  function test_timeDisplayOnDaylighTimeTransition() {
    // US PST transition to PDT on 2006/4/2/ 2:00am, jump to 2006/4/2 3:00am,
    var date = new Date(Date.UTC(2006, 4 - 1, 2, 2, 30, 0));
    var timeZone = goog.locale.TimeZone.createTimeZone(0);
    assertEquals("04/02/2006 02:30:00 +0000",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss Z").format(
        date, timeZone));

    // US PDT transition to PST on 2006/10/29/ 2:00am, jump back to PDT
    // 2006/4/2 1:00am,
    date = new Date(Date.UTC(2006, 10 - 1, 29, 1, 30, 0));
    assertEquals("10/29/2006 01:30:00 +0000",
        goog.locale.getDateTimeFormatter("MM/dd/yyyy HH:mm:ss Z").format(
        date, timeZone));
  }
</script>
</body>
</html>
